package com.ruoyi.common.utils;

import com.ruoyi.common.core.domain.R;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName : CollectionUtils
 * @Description :
 * @Author :
 * @Date: 2023-01-25 22:14
 */
public class CollectionUtils {

    public static <T,R>  List<R> convertCollectionType(List<T> infoList,Class R)
    {
//        List<ProductInfo> infoList = productInfoMapper.selectProductInfoList(productInfo);
        return infoList.stream().map((lis)->{
            R ListVo = null;
            try {
                ListVo = (R) R.newInstance();
            } catch (InstantiationException e) {
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
            BeanUtils.copyProperties(lis,ListVo);
            return ListVo;
        }).collect(Collectors.toList());
    }
}
